# $Id: PKGBUILD 157784 2012-04-29 11:28:45Z allan $
# Maintainer: AndyRTR <andyrtr@archlinux.org>

pkgname=hunspell-en
pkgver=7.1
pkgrel=2
pkgdesc="English hunspell dictionaries"
arch=(any)
#url="http://en-gb.pyxidium.co.uk/"
url="http://wordlist.sourceforge.net/"
license=('LGPL' 'custom:scowl')
optdepends=('hunspell:	the spell checking libraries and apps')
source=(http://downloads.sourceforge.net/wordlist/hunspell-en_US-$pkgver-0.zip
	http://downloads.sourceforge.net/wordlist/hunspell-en_CA-$pkgver-0.zip
	http://en-gb.pyxidium.co.uk/dictionary/en_GB.zip)
md5sums=('8eb485db0a722eb29a5eca517a22e367'
         '1921a5011d0f34e17d2e3f050d62a2c8'
         '218909136738f4564b81ecd145ade6ee')

build() {
 /bin/true
}

package() {
  cd "$srcdir"
  install -dm755 ${pkgdir}/usr/share/hunspell
  install -m644 en_*.dic en_*.aff $pkgdir/usr/share/hunspell

  pushd $pkgdir/usr/share/hunspell/
  en_GB_aliases="en_AG en_AU en_BS en_BW en_BZ en_DK en_GH en_HK en_IE en_IN en_JM en_NA en_NG en_NZ en_SG en_TT en_ZA en_ZW"
  for lang in $en_GB_aliases; do
	ln -s en_GB.aff $lang.aff
	ln -s en_GB.dic $lang.dic
  done
  en_US_aliases="en_PH"
  for lang in $en_US_aliases; do
	ln -s en_US.aff $lang.aff
	ln -s en_US.dic $lang.dic
  done
  popd

  # the symlinks
  install -dm755 ${pkgdir}/usr/share/myspell/dicts
  pushd $pkgdir/usr/share/myspell/dicts
    for file in $pkgdir/usr/share/hunspell/*; do
      ln -sv /usr/share/hunspell/$(basename $file) .
    done
  popd
  
  # docs
  install -dm755 ${pkgdir}/usr/share/doc/$pkgname
  install -m644 README_en_??.txt $pkgdir/usr/share/doc/$pkgname

  # licenses
  install -D -m644 README_en_US.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_US
  install -D -m644 README_en_CA.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_CA
  install -D -m644 README_en_GB.txt $pkgdir/usr/share/licenses/$pkgname/Copyright_en_GB
}
